using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Youshow.Ace.Domain.Models;

namespace BlogSystem.Domain.NewsInfo
{
    public class News:BaseModel<int>
    {
        [Comment("文章作者")]
        [Column("author")]
        public string Author { get; set; }

        [Comment("文章标题")]
        [Column("title")]
        public string Title { get; set; }

        [Comment("文章内容")]
        [Column("content")]
        public string Content { get; set; }

        [Comment("文章摘要")]
        [Column("key")]
        public string Key { get; set; }
        
        [Comment("文章类型Id")]
        [Column("category_id")]
        public int CategoryId { get; set; }

        [Comment("文章类型名称")]
        [Column("category_name")]
        public string CategoryName { get; set; }

        [Comment("回复数")]
        [Column("hit")]
        public int Hit { get; set; }

        [Comment("文章回复数")]
        [Column("reply_count")]
        public int ReplyCount { get; set; }

        [Comment("发布时间")]
        [Column("publish_time")]
        public DateTime PublishTime { get; set; }

        /// <summary>
        /// 敏感词过滤
        /// </summary>
        /// <returns></returns>
        public void ContentFiler()
        {
             this.Content.Replace("","");
             this.Title.Replace("","");
             this.Key.Replace("","");
        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="categoryName"></param>
        public void InitNews(string categoryName)
        {   
            ContentFiler();
            this.PublishTime = DateTime.Now;
            this.Hit = 0;
            this.ReplyCount = 0;
            this.CategoryName = categoryName;

        }
    }
}